package com.demo.fenye;

import java.util.List;

import com.example.jiemian.R;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter{

	private List<Bitmap> bitmaps;
	private Context context;
	public ImageAdapter(Context context, List<Bitmap> bitmaps){
		this.context=context;
		this.bitmaps=bitmaps;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return bitmaps.size();
	}
	

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return bitmaps.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		ViewHolder holder;
		if(convertView==null){
			convertView=View.inflate(context, R.layout.fenye_gallery_item, null);
			holder=new ViewHolder();
			holder.image=(ImageView) convertView.findViewById(R.id.fenye_changge);
			convertView.setTag(holder);
		}else{
			holder=(ViewHolder) convertView.getTag();
		}
		holder.image.setImageBitmap(bitmaps.get(position)); 	
		return convertView;	
	}
	public  class ViewHolder{
		public   ImageView  image;
	}
}
